package com.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.domain.DO.FlightClass;
import com.domain.DTO.FlightClassDto;
import com.domain.VO.FlightClassVO;
import com.mapper.FlightClassMapper;
import com.service.IFlightClassService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.domain.factory.FlightClassFactory.FLIGHT_CLASS_CONVERT;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 大忽悠
 * @since 2022年11月08日
 */
@Service
public class FlightClassServiceImpl extends ServiceImpl<FlightClassMapper, FlightClass> implements IFlightClassService {

    @Override
    public void save(FlightClassVO flightClassVO) {
        FlightClass flightClass = FLIGHT_CLASS_CONVERT.toFlightClass(flightClassVO);
        save(flightClass);
    }

    @Override
    public List<FlightClassDto> list(Integer flightId) {
        return FLIGHT_CLASS_CONVERT.toFlightClassDto(list(new QueryWrapper<FlightClass>().eq("flight_id",flightId)));
    }
}
